﻿using Dqs_DAL;
using Model;

namespace Dqs_BLL
{
    public class Teacher_BLL
    {
        Teacher_DAL teacher_DAL = new Teacher_DAL();

        public TeacherInfo IsLoginOfTeacher(string name, string pwd)
        {
            return teacher_DAL.IsLoginOfTeacher(name, pwd);
        }

		public List<TeacherInfo> GetTeachers()
		{
			return teacher_DAL.QueryTeacherInfo();
		}

		

		public string GetTeacherName(int id)
		{
			foreach (var temp in teacher_DAL.QueryTeacherInfo())
			{
				if (temp.Id == id)
				{
					return temp.FullName!;
				}
			}
			return "";
		}


		public bool InsertTeacherInfo(TeacherInfo teacherInfo)
		{
			return teacher_DAL.InsertTeacherInfo(teacherInfo);
		}

		public bool UpdateTeacherInfoById(TeacherInfo teacherInfo)
		{
			return teacher_DAL.UpdateTeacherInfoById(teacherInfo);
		}

		public bool DeleteTeacherInfoById(int teacherId)
		{
			return teacher_DAL.DeleteTeacherInfoById(teacherId);
		}


		public List<TeacherInfo> GetTeacherInfoBySpellOrNum(string str, int type)
		{
			List<TeacherInfo> list = new List<TeacherInfo>();
			foreach (var temp in teacher_DAL.QueryTeacherInfo())
			{
				if (type == 1)
				{
					if (temp.TeaNum!.Contains(str))
					{
						list.Add(temp);
					}
				}
				else if (type == 2)
				{
					if (temp.FullName!.Contains(str))
					{
						list.Add(temp);
					}
				}
			}
			return list;
		}
	}
}
